package com.koi.system.config.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @program: ruoyi
 * @description: 日期加30位随机字母
 * @author: hongcai
 * @create: 2021-12-10
 **/
public class IdxRandom {


    public static String getRandom(int length) {
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
        String dateNumber = sf.format(new Date());

        //随机字符串的随机字符库
        String keyString = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ0123456789";
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            sb.append(keyString.charAt(random.nextInt(keyString.length())));
        }
        return dateNumber+sb.toString();
    }

    public static void main(String[] args) {
        /*
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
        String dateNumber = sf.format(new Date());
        System.out.println("dateNumber-->"+dateNumber);
        */
        for(int i = 0;i < 5000; i++) {
            String random = IdxRandom.getRandom(32);
            System.out.println(random);
        }

    }

}